package ldh.im.fxgui.demo;

import com.dustinredmond.fxtrayicon.FXTrayIcon;
import javafx.application.Application;
import javafx.scene.control.MenuItem;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import ldh.im.fxbase.util.SvgUtil;

public class TestBareFXTrayIcon extends Application {

    @Override
    public void start(Stage stage) throws Exception {
        stage.setTitle("Test FXTrayIcon with empty menu");
        Image icon = SvgUtil.loadSvg(this.getClass().getResource("/webrtc-img/close.svg").toExternalForm());
        String imageUrl = getClass().getResource("/imgs/icon.jpg").toExternalForm();
        FXTrayIcon trayIcon = new FXTrayIcon(stage, icon);

//        File[]  files = new File("e:/git/im/fx-gui/resources/imgs/").listFiles();
//        LinkedList<File> fileList = new LinkedList<>(Arrays.asList(files));
//        fileList.sort(Comparator.comparing(File::getName));
//
//        FXTrayIcon trayIcon = new FXTrayIcon.Builder(stage, getClass().getResource("/imgs/icon.jpg"))
////                .addExitMenuItem("Exit", e -> {
////                    stage.close();
////                })
//                .show()
//                .build();
        trayIcon.addMenuItems(new MenuItem("exit"), new MenuItem("打开"));
        trayIcon.show();
        stage.show();

        trayIcon.showMessage("login success!!");
    }

    public static void main(String[] args) {
        Application.launch(TestBareFXTrayIcon.class);
    }
}
